home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic new SourceCode and Projects / System Speed Test / Win32API.bas < prev   
Encoding:
BASIC Source File  |  1998-09-30  |  6.7 KB  |  154 lines

  1. Attribute VB_Name = "modWin32api"
  2.  
  3. Public Type RECT
  4.     left As Long
  5.     top As Long
  6.     right As Long
  7.     bottom As Long
  8. End Type
  9.  
  10. Public Type SYSTEM_INFO
  11.         dwOemID As Long
  12.         dwPageSize As Long
  13.         lpMinimumApplicationAddress As Long
  14.         lpMaximumApplicationAddress As Long
  15.         dwActiveProcessorMask As Long
  16.         dwNumberOfProcessors As Long
  17.         dwProcessorType As Long
  18.         dwAllocationGranularity As Long
  19.         wProcessorLevel As Integer
  20.         wProcessorRevision As Integer
  21. End Type
  22.  
  23. Public Type MEMORYSTATUS
  24.     dwLength As Long
  25.     dwMemoryLoad As Long
  26.     dwTotalPhys As Long
  27.     dwAvailPhys As Long
  28.     dwTotalPageFile As Long
  29.     dwAvailPageFile As Long
  30.     dwTotalVirtual As Long
  31.     dwAvailVirtual As Long
  32. End Type
  33.  
  34. Public Type LARGE_INTEGER
  35.     lowpart As Long
  36.     highpart As Long
  37. End Type
  38.  
  39. Public Type OSVERSIONINFO
  40.         dwOSVersionInfoSize As Long
  41.         dwMajorVersion As Long
  42.         dwMinorVersion As Long
  43.         dwBuildNumber As Long
  44.         dwPlatformId As Long
  45.         szCSDVersion As String * 128      '  Maintenance string for PSS usage
  46. End Type
  47.  
  48. Public Type FREQ_INFO
  49.     in_cycles As Long    ' Internal clock cycles during
  50.     ex_ticks As Long     ' Microseconds elapsed during
  51.     raw_freq As Long     ' Raw frequency of CPU in MHz
  52.     norm_freq As Long    ' Normalized frequency of CPU
  53. End Type
  54.  
  55.  
  56.  
  57. '  DrawText() Format Flags
  58. Public Const DT_TOP = &H0
  59. Public Const DT_LEFT = &H0
  60. Public Const DT_CENTER = &H1
  61. Public Const DT_RIGHT = &H2
  62. Public Const DT_VCENTER = &H4
  63. Public Const DT_BOTTOM = &H8
  64. Public Const DT_WORDBREAK = &H10
  65. Public Const DT_SINGLELINE = &H20
  66. Public Const DT_EXPANDTABS = &H40
  67. Public Const DT_TABSTOP = &H80
  68. Public Const DT_NOCLIP = &H100
  69. Public Const DT_EXTERNALLEADING = &H200
  70. Public Const DT_CALCRECT = &H400
  71. Public Const DT_NOPREFIX = &H800
  72. Public Const DT_INTERNAL = &H1000
  73.  
  74. ' functions contained in the cpuinf32.dll file
  75. Public Declare Function CPUIDSupport Lib "cpuinf32" Alias "wincpuidsupport" () As Long
  76. Public Declare Function CPUID Lib "cpuinf32" Alias "wincpuid" () As Long
  77. Public Declare Function CPUIDExt Lib "cpuinf32" Alias "wincpuidext" () As Long
  78. Public Declare Function CPUFeatures Lib "cpuinf32" Alias "wincpufeatures" () As Long
  79. Public Declare Function CPUCount Lib "cpuinf32" Alias "ProcessorCount" () As Long
  80. Public Declare Function CPUSpeed Lib "cpuinf32" Alias "cpurawspeed" () As Long
  81. Public Declare Function CPUNormSpeed Lib "cpuinf32" Alias "cpuspeed" () As FREQ_INFO
  82.  
  83. Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
  84. Public Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
  85. Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  86. Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  87. Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  88. Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  89. Public Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)
  90. Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  91. Public Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
  92. Public Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
  93. Public Declare Function GetTickCount Lib "kernel32" () As Long
  94. Public Declare Function GetKeyboardType Lib "user32" (ByVal nTypeFlag As Long) As Long
  95. Public Declare Function IsProcessorFeaturePresent Lib "wnaspi32" (ByVal ProcessorFeature As Long) As Boolean
  96. Public Declare Function GetEnvironmentStrings Lib "kernel32" Alias "GetEnvironmentStringsA" () As String
  97. Public Declare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As Long
  98. Public Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
  99. Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  100. Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
  101. Public Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
  102.  
  103. Public Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  104. Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  105. Public Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
  106. Public Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
  107. Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
  108.  
  109. Global myVer As OSVERSIONINFO
  110.  
  111. Public Function run(sProgram As String, bPause As Boolean) As Long
  112.     Dim retval
  113.     Dim temp As String
  114.         
  115.     retval = Shell(sProgram, vbNormalFocus)
  116.         
  117.     If bPause Then
  118.         frmSpawn.lblSpawn = sProgram
  119.         frmSpawn.Show vbModal
  120.     End If
  121.     
  122.     run = retval
  123. End Function
  124.  
  125.  
  126. Public Function getWindowsDir()
  127.     Dim temp$
  128.     Dim Value
  129.     
  130.     Value = GetWindowsDirectory(temp, 0)
  131.     If Value <> 0 Then
  132.         getWindowsDir = temp
  133.     Else
  134.         getWindowsDir = "error"
  135.     End If
  136.     
  137. End Function
  138.  
  139. '
  140. ' Extracts a VB string from a buffer containing a null terminated
  141. ' string
  142. Public Function LPSTRToVBString$(ByVal s$)
  143.     Dim nullpos&
  144.     nullpos& = InStr(s$, Chr$(0))
  145.     If nullpos > 0 Then
  146.         LPSTRToVBString = left$(s$, nullpos - 1)
  147.     Else
  148.         LPSTRToVBString = ""
  149.     End If
  150. End Function
  151.  
  152.  
  153.  
  154.